/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1623376746707_6613';

  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  // 配置跨域
  config.security = {
    csrf: {
      enable: false,
      ignoreJSON: true
    },
    domainWhiteList: ['http://localhost:8080']
  };
  config.cors = {
    origin:'*',
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH'
  };

  // 配置mongodb数据库
  config.mongoose = {
    url: 'mongodb://127.0.0.1/mobile',
    options: {}
  }

  // 配置redis密码和数据库密码和端口
  config.redis = {
    client: {
      port: 6379,
      host: '127.0.0.1',
      password: '',
      db: 0
    }
  }

  config.jwt = {
    secret: '123456' // 定义token加密条件字符串
  }

  config.result = {
    SUCCESS: {
      errno: 1000,
      errmsg: '成功'
    },
    ERROR: {
      errno: 1002,
      errmsg: '失败'
    },
    EXCEPTION: {
      errno: 1004,
      errmsg: '出现异常'
    },
    PARA_MISS: {
      errno: 1006,
      errmsg: '缺少必要参数'
    },
    PARA_ERROR: {
      errno: 1008,
      errmsg: '参数格式错误'
    },
    USER_NOT_FOUND: {
      errno: 1016,
      errmsg: '用户不存在'
    },
    LOGIN_FAIL: {
      errno: 1018,
      errmsg: '账号或密码不正确'
    },
    NOT_EXIST: {
      errno: 1022,
      errmsg: '不存在'
    }
  }

  config.bodyParser = {
		formLimit: '3mb',
    jsonLimit: '3mb',
    textLimit: '3mb'
    // 值的大小可以根据自己的需求修改 这里只做演示
	}

  return {
    ...config,
    ...userConfig,
  };
};
